<template>
  <div id="app">
    <loading v-model="isLoading"></loading>
  	<transition :name="transitionName" mode="out-in">
    	<router-view></router-view>
    </transition>
  <vfooter></vfooter>

  <vlogin v-if="$store.state.loginbg" @closeBg="closeBg"></vlogin>
  </div>
</template>

<script>
import vfooter from '@/components/footer'
import vloading from '@/components/loading'


import { Cell,Loading } from 'vux'
import { mapState } from 'vuex'
import axios from 'axios'

import vlogin from '@/components/login'
import {GetToken} from '@/config/api.js'

export default {
  name: 'app',
  created:function(){
    if(!this.vCheck()){
      this.getToken()
    }else{
      this.vLogin()
    }
  },
  computed: {
    ...mapState({
      isLoading: 'isLoading',
      transitionName:'transitionName'
    })
  },
  components:{
  	vfooter,vlogin,vloading,Loading
  },
  methods:{
    //关闭登录窗口
    closeBg(){
      this.$store.dispatch("closeBg");
    },
    async getToken(){
        let data= await GetToken()
        let token=data.data.access_token
        var arr = token.split('');
        var passToken = "";
        for (var i = 0; i < token.length; i++) {
          passToken += arr[i].charCodeAt()*3;
          passToken += "/";
        }
        var lastToken = passToken.substring(0, passToken.length - 1)
        var d = new Date();
        d.setTime(d.getTime() + (604800000));
        var expires = "expires=" + d.toUTCString();
        document.cookie = "bedtoken" + "=" + lastToken + "; " + expires;
        this.$store.dispatch("tokensync",token);
        window.location.reload();
      }
  }
}

</script>

<style lang="scss" type="text/css">
html {-webkit-text-size-adjust: none;-ms-text-size-adjust: none;font-family: "黑体";}

input[type="submit"],input[type="reset"],input[type="button"],input:focus,button:focus,select:focus,textarea:focus{ outline: none;}
input{font-family: "黑体";-webkit-appearance:none; resize: none; border-radius: 0;}
body,div,ul,li,ol,h1,h2,h3,h4,h5,h6,input,textarea,select,p,dl,dt,dd,a,img,button,form,table,th,tr,td,tbody,article, 
aside, details,figcaption,figure,footer,header,hgroup, menu,nav,section{ -webkit-tap-highlight-color:rgba(0, 0, 0, 0); }

article, aside, details,figcaption,figure,footer,header,hgroup, menu,nav,section {display: block;}

img {max-width: 100%;height: auto;width:auto; -ms-interpolation-mode:bicubic;}

body,div,ul,li,ol,h1,h2,h3,h4,h5,h6,input,textarea,select,p,dl,dt,dd,a,img,button,form,table,th,tr,td,tbody,article, 
aside, details,figcaption,figure,footer,header,hgroup, menu,nav,section{margin:0; padding:0; border:none;}
body{font-family: "微软雅黑";}
em,i{font-style:normal;}
strong{font-weight: normal;}
.clearfix:after{content:""; display:block; visibility:hidden; height:0; clear:both;}
.clearfix{zoom:1;}
a{text-decoration:none; color:#333; font-family: '黑体',Microsoft YaHei,Tahoma,Arial,sans-serif;}
a:hover{color:#FED503; text-decoration:none;}
ul,ol{list-style:none;}
h1, h2, h3, h4, h5, h6{ font-size:100%; font-family: Microsoft YaHei;}
img{border: none;}


$vw:750;
@function h($px){@return $px/$vw*100vw}


.allTitle{text-align: center;line-height: h(90);font-size: h(36);color:#38b6f0;background: #fff;margin-bottom: h(10);position: relative;}
.allTitle a{width: h(90);height: h(90);position: absolute;left: 0;top: 0;background: url('/static/images/heiBack.png') no-repeat;background-size: 100%;}

.loading{text-align: center;padding: h(20)}
.loading span{width: h(120);height: h(120);background: url('/static/images/load.gif');background-size: 100%;display:inline-block;}


.go-enter-active,.go-leave-active{
  transition: all .2s
}
.go-enter{
  transform: translateX(100%)
}
.go-leave-active{
  transform: translateX(-100%)
}


.back-enter-active,.back-leave-active{
  transition: all .2s
}
.back-enter{
  transform: translateX(-100%)
}
.back-leave-active{
  transform: translateX(100%)
}


</style>
